/**
 * @param {string} s
 * @return {string}
 */
 var removeDuplicates = function(s) {
    let n = s.length
    let stack = []
    for(let i = 0;i<n;i++){
        if(stack.length==0||stack[stack.length-1]!==s[i]){
            stack.push(s[i])
        }else if(stack[stack.length-1]===s[i]){
            stack.pop()
        }
    }
    return stack.join('')
};
//console.log(removeDuplicates("abbaca"));